package com.aaa.security;

import org.springframework.security.crypto.password.PasswordEncoder;

public class MyPasswordEncoder implements PasswordEncoder {
    // 编码
    @Override
    public String encode(CharSequence charSequence) {
        System.out.println("charSequence:" + charSequence.toString());
        return "456";
    }

    /**
     * 拿着表单提交的密码与真实密码做比对,判断密码是否正确
     * @param charSequence:表单提交的密码
     * @param s:正确密码
     * @return true认证成功,false认证失败
     */
    @Override
    public boolean matches(CharSequence charSequence, String s) {
        System.out.println("c:" + charSequence.toString());
        System.out.println("s:" + s.toString());
        return charSequence.toString().equals(s);
    }
}
